package com.lzy.cloud.goods.service.GoodsServiceImpl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzy.cloud.goods.dtos.CarRecommendDto;
import com.lzy.cloud.goods.entity.CarRecommend;
import com.lzy.cloud.goods.mapper.CarRecommendMapperExt;
import com.lzy.cloud.goods.service.CarRecommendService;
import com.lzy.framework.core.orm.db.Pager;
import com.lzy.framework.core.utils.DozerUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by WIN7 on 2018/6/9.
 */
@Service
public class CarRecommendServiceImpl implements CarRecommendService{

    @Autowired
    CarRecommendMapperExt carRecommendMapperExt;

    @Override
    public Boolean add(CarRecommendDto dto) {
        return carRecommendMapperExt.insertSelective(DozerUtils.map(dto,CarRecommend.class))>0;
    }

    @Override
    public Boolean delById(Long id) {
        return carRecommendMapperExt.deleteByPrimaryKey(id)>0;
    }

    @Override
    public Boolean update(CarRecommendDto dto) {
        return carRecommendMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto,CarRecommend.class))>0;
    }

    @Override
    public PageInfo<CarRecommendDto> selectList(Pager pager, CarRecommendDto dto) {
        if (pager != null)
            PageHelper.startPage(pager.getPageNum(), pager.getPageSize());
        return new PageInfo<>(carRecommendMapperExt.selectList(dto));
    }

    @Override
    public CarRecommendDto selectById(Long id) {
        return DozerUtils.map(carRecommendMapperExt.selectByPrimaryKey(id),CarRecommendDto.class);
    }
}
